//
//  Products_TableView_Cell.m
//  Time
//
//  Created by dllo on 16/8/1.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "Products_TableView_Cell.h"

@interface Products_TableView_Cell ()
/**
 *  图片
 */
@property (nonatomic,retain) UIImageView *productsImageView;
/**
 *  标题
 */
@property (nonatomic,retain) UILabel *titleLabel;
/**
 *  文本内容
 */
@property (nonatomic,retain) UILabel *contentLabel;
/**
 *  分享按钮
 */
@property (nonatomic,retain) UIButton *shareButton;
/**
 *  评论按钮
 */
@property (nonatomic,retain) UIButton *commentsButton;
/**
 *  评论数
 */
@property (nonatomic,retain) UILabel *commentsLabel;
/**
 *  收藏按钮
 */
@property (nonatomic,retain) UIButton *likesButton;
/**
 *  收藏数
 */
@property (nonatomic,retain) UILabel *likesLabel;

@end

@implementation Products_TableView_Cell

-(void)dealloc{
    [_productsImageView release];
    [_titleLabel release];
    [_contentLabel release];
    [_shareButton release];
    [_commentsButton release];
    [_commentsLabel release];
    [_likesButton release];
    [_likesLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.productsImageView = [[UIImageView alloc] init];
        self.productsImageView.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:self.productsImageView];
        [_productsImageView release];
        
        self.titleLabel = [[UILabel alloc] init];
        //        self.titleLabel.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.contentLabel = [[UILabel alloc] init];
        //        self.contentLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.contentLabel];
        [_contentLabel release];
        
        self.shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.shareButton addTarget:self action:@selector(shareButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.shareButton];
        [_shareButton release];
        
        self.likesButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.likesButton addTarget:self action:@selector(likesButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.likesButton];
        [_likesButton release];
        
        self.likesLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.likesLabel];
        [_likesLabel release];
        
        self.commentsButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.commentsButton addTarget:self action:@selector(commentsButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.commentsButton];
        [_commentsButton release];
        
        self.commentsLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.commentsLabel];
        [_commentsLabel release];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.productsImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.productsImageView.clipsToBounds = YES;
    [self.productsImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(10);
        make.top.equalTo(self.contentView.mas_top).offset(0);
        make.height.mas_equalTo(180);
    }];
    
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font = [UIFont systemFontOfSize:24.0];
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.top.equalTo(self.productsImageView.mas_bottom).offset(20);
        make.height.mas_equalTo([Tools getTextHeight:self.model.title withWidth:SWIDTH - 20 withFontSize:24.0]);
    }];
    
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.font = [UIFont systemFontOfSize:17.0];
    [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(20);
        make.height.mas_equalTo([Tools getTextHeight:self.model.text withWidth:SWIDTH - 20 withFontSize:17.0]);
    }];
    
    self.likesLabel.textColor = [UIColor lightGrayColor];
    self.likesLabel.font = [UIFont systemFontOfSize:15.0];
    [self.likesLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.top.equalTo(self.contentLabel.mas_bottom).offset(20);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
    }];
    
#warning continue
}



@end
